{% if not is_xhr|default(false) %}{% extends "base.html" %}{% endif -%}
{% block content %}
    <div id="dashboard">
        <div class="box cpu">
            <div class="box-header">
                <span>CPU</span>
            </div>
            <div class="box-content">
                <table class="table">
                    <tr>
                        <td class="label-col">平均负载</td>
                        <td class="load" style="word-spacing: 10px;">{{ load_avg[0]|round(2) }} {{ load_avg[1]|round(2) }} {{ load_avg[2]|round(2) }}</td>
                    </tr>
                    <tr>
                        <td class="label-col">用户</td>
                        <td class="user">{{ cpu.user }} %</td>
                    </tr>
                    <tr>
                        <td class="label-col">系统</td>
                        <td class="system">{{ cpu.system }} %</td>
                    </tr>
                    <tr>
                        <td class="label-col">闲置</td>
                        <td class="idle">{{ cpu.idle }} %</td>
                    </tr>
                    <tr>
                        <td class="label-col">I/O 等待</td>
                        <td class="iowait">{{ cpu.iowait }} %</td>
                    </tr>
                    <tr>
                        <td class="label-col">内核</td>
                        <td class="iowait">{{ num_cpus }}</td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="box memory">
            <div class="box-header">
                <span>内存</span>
            </div>
            <div class="box-content">
                <table class="table">
                    <tr>
                        <td class="label-col">总计</td>
                        <td class="total">{{ memory.total|filesizeformat }}</td>
                    </tr>
                    <tr>
                        <td class="label-col">可用</td>
                        <td class="available">{{ memory.available|filesizeformat }}</td>
                    </tr>
                    <tr>
                        <td class="label-col">已使用 <small>(不包括缓存 &amp; 缓冲区)</small></td>
                        <td class="used_excl">{{ (memory.total - memory.available)|filesizeformat }} ({{ memory.percent }} %)</td>
                    </tr>
                    <tr>
                        <td class="label-col">已使用 <small>(包括缓存 &amp; 缓冲区)</small></td>
                        <td class="used_incl">{{ memory.used|filesizeformat }}</td>
                    </tr>
                    <tr>
                        <td class="label-col">空闲内存</td>
                        <td class="free">{{ memory.free|filesizeformat }}</td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="box network">
            <div class="box-header">
                <span>网络</span>
            </div>
            <div class="box-content">
                <table class="table">
                    <thead>
                        <tr>
                            <th>接口</th>
                            <th>IP</th>
                            <th>上行速率/s</th>
                            <th>下行速率/s</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for ni in net_interfaces %}
                            <tr>
                                <td>{{ ni.name}}</td>
                                <td>{{ ni.ip }}</td>
                                <td>{{ ni.send_rate|default(0)|filesizeformat }}</td>
                                <td>{{ ni.recv_rate|default(0)|filesizeformat }}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="box disks">
            <div class="box-header">
                <span>磁盘</span>
            </div>
            <div class="box-content">
                <table class="table">
                    <thead>
                        <tr>
                            <th>设备</th>
                            <th>已挂载</th>
                            <th>总计</th>
                            <th>使用</th>
                            <th>空闲</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for d in disks %}
                            <tr>
                                <td>{{ d.device }}</td>
                                <td>{{ d.mountpoint }}</td>
                                <td>{{ d.space_total|filesizeformat }}</td>
                                <td>{{ d.space_used|filesizeformat }} ({{ d.space_used_percent }} %)</td>
                                <td>{{ d.space_free|filesizeformat }}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
        <div class="box swap">
            <div class="box-header">
                <span>交换</span>
            </div>
            <div class="box-content">
                <table class="table">
                    <tr>
                        <td class="label-col">总计</td>
                        <td class="total">{{ swap.total|filesizeformat }}</td>
                    </tr>
                    <tr>
                        <td class="label-col">已使用</td>
                        <td class="used">{{ swap.used|filesizeformat }} ({{ swap.percent }} %)</td>
                    </tr>
                    <tr>
                        <td class="label-col">空闲</td>
                        <td class="free">{{ swap.free|filesizeformat }}</td>
                    </tr>
                    <tr>
                        <td class="label-col">换入</td>
                        <td class="swapped-in">{{ swap.swapped_in|filesizeformat }}</td>
                    </tr>
                    <tr>
                        <td class="label-col">换出</td>
                        <td class="swapped-out">{{ swap.swapped_out|filesizeformat }}</td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="box users">
            <div class="box-header">
                <span>用户</span>
            </div>
            <div class="box-content">
                <table class="table">
                    <thead>
                        <tr>
                            <th>用户</th>
                            <th>时间</th>
                            <th>域</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for u in users %}
                            <tr>
                                <td>{{ u.name }}</td>
                                <td>{{ u.started|fromtimestamp }}</td>
                                <td>{{ u.host }}</td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
{% endblock %}
